from django.conf.urls import url
from rest_auth import views as auth_views

from api import views
from api.views import wx as wx_views

urlpatterns = [
    # rest auth
    url(r'^password/forget/$', views.forget_password),
    url(r'^password/reset/$', views.reset_password),
    url(r'^login/$', auth_views.LoginView.as_view(), name='rest_login'),
    url(r'^login-sms/$', views.login_with_sms_code),
    # URLs that require a user to be logged in with a valid session / token.
    url(r'^logout/$', auth_views.LogoutView.as_view(), name='rest_logout'),
    url(r'^user/$', auth_views.UserDetailsView.as_view(), name='rest_user_details'),
    url(r'^register/$', views.RegisterView.as_view()),
    url(r'^user-info/$', views.get_user_info),

    # category
    url(r'^category/$', views.get_category_list),
    url(r'^category/(?P<category_id>[0-9]+)/$', views.get_category_detail),
    # product
    url(r'^category/(?P<category_id>[0-9]+)/products/$', views.get_product_list),
    url(r'^product/(?P<product_id>[0-9]+)/$', views.get_product_detail),
    # order
    url(r'^pre-order/$', views.add_pre_order),
    url(r'^pre-order/re-add/$', views.re_add_pre_order),
    url(r'^order/status/(?P<order_status>[0-9](,[0-9])*)/$', views.get_order_list),
    url(r'^order/$', views.get_order_list),
    url(r'^order/(?P<order_id>[0-9]+)/$', views.get_order_detail),
    url(r'^order/add/$', views.add_order),
    url(r'^order/cancel/$', views.cancel_order_status),
    url(r'^order/delete/(?P<order_id>[0-9]+)/$', views.delete_order),
    url(r'^order/confirm/$', views.confirm_order),
    url(r'^order/return-deposit/$', views.request_return_deposit),
    # cart
    url(r'^cart/$', views.get_user_cart),
    url(r'^cart/delete/$', views.delete_user_cart),
    url(r'cart/update/$', views.update_user_cart),
    url(r'^cart/add/$', views.add_user_cart),
    # address
    url(r'^address/$', views.get_user_address),
    url(r'^address/delete/(?P<address_id>[0-9]+)/$', views.delete_user_address),
    url(r'^address/update/(?P<address_id>[0-9]+)/$', views.update_user_address),
    url(r'^address/add/$', views.add_user_address),
    url(r'^address/default/(?P<address_id>[0-9]+)/$', views.set_default_user_address),
    # search
    url(r'^search/(?P<keyword>[\u4e00-\u9fa5a-zA-z0-9 ]+)/$', views.search),
    url(r'^search/product-name/(?P<keyword>[\u4e00-\u9fa5a-zA-z0-9]+)/$', views.search_product_name),
    url(r'^hot-keywords/$', views.get_hot_keywords),
    # pay
    url(r'^pay-method/$', views.get_pay_method),
    url(r'^pay/$', views.pay),
    url(r'^weixin_pay_callback', views.wxpay_notify),
    # banner
    url(r'^banners/$', views.get_banners),
    # common product
    url(r'^common-products/$', views.get_common_products),
    # sms
    url(r'^sms-code/$', views.get_sms_code),
    url(r'^sms-code/validate/$', views.validate_sms_code),
    # wish product
    url(r'^wish-product/add/$', views.add_wish_product),
    # feedback
    url(r'^feedback/add/$', views.add_feedback),
    # wxpay
    url(r'wxpay/notify/$', views.wxpay_notify),

    # wx
    url(r'^wx/login/$', wx_views.login_with_sms_code),
    url(r'^wx/order/status/(?P<order_status>[0-9](,[0-9])*)/$', wx_views.get_order_list),
    url(r'^wx/order/$', wx_views.get_order_list),
    # url(r'^wx/order/(?P<order_id>[0-9]+)/$', wx_views.get_order_detail),
    # url(r'^wx/order/add/$', wx_views.add_order),
    # url(r'^wx/order/cancel/$', wx_views.cancel_order_status),
    # url(r'^wx/order/delete/(?P<order_id>[0-9]+)/$', wx_views.delete_order),
    url(r'^wx/order/confirm/$', wx_views.confirm_order),
    url(r'^wx/order/shipped-order/$', wx_views.shipped_order),
]
